{include file="public/header"}

<title>详情</title>
<link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-select/1.14.0-beta/css/bootstrap-select.css" rel="stylesheet">
</head>
<style>
    td {
        text-align: center !important;
    }

    .ch-more-row-button {
        display: none;
    }

    .ch-info-form {
        line-height: 1;
    !important;
    }

    .ck {
        display: block;
        height: 34px;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.42857143;
        color: #555;
        background-color: #fff;
        background-image: none;
        border: 1px solid #ccc;
        border-radius: 4px;
    "

    }

    .yin input + label {
        vertical-align: middle;
        width: 0.3rem;
        height: 0.3rem;
    / / 设置合适的宽高 background-size: contain;
    }

   .yin input:checked + label {

        background-size: contain;
        color: #FF7244;
    }
    .yin{
        width:250px;
        height:auto;
        color:#333;
        filter:progid:DXImageTransform.Microsoft.Shadow(color=#909090,direction=120,strength=4);
        -moz-box-shadow: 2px 2px 10px #909090;
        -webkit-box-shadow: 2px 2px 10px #909090;
        box-shadow:2px 2px 10px #909090;
        margin-bottom: 12px;
        margin-left: 12px;
    }
</style>

<div class="page-container jijianfu" style="position: relative;margin: 0 auto ;">
    <form action="" method="post" class="form form-horizontal" id="form-member-add">
        <h2 class="ch-info-title"><span class="glyphicon glyphicon-file"></span>基础信息</h2>
        <div class="ch-row ch-info-form">
            <p class="flex">方案类别：</p>
            <div class="flex2" style="margin-top: 9px;" id="scheme_category">
                {volist name="goods_category" id="vo" key="k" }
                <label class="checkbox-inline">
                    <input type="checkbox"  class="schemeCategory" id="inlineCheckbox{$k}" value="{$vo.id},{$vo.title}" data-id="{$vo.id}" name="scheme_category"> {$vo.title}
                </label>
                {/volist}

            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex">方案名称：</p>
            <div class="flex2">
                <input type="text" class="form-control fid" name="store_name" placeholder="请输入方案名称"
                       style="width: 50%">
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex">选择城市：</p>
            <div class="flex2">
                <select name="province" class="province1 col-xs-7 col-sm-2 ck">
                    <option selected="selected">请选择地址</option>
                </select>
                <select name="city" class="city1 col-xs-7 col-sm-3 ck">
                    <option selected="selected">请选择地址</option>
                </select>
                <select name="area" class="area1 col-xs-7 col-sm-3 ck">
                    <option selected="selected">请选择地址</option>
                </select>
            </div>
        </div>

        <div class="ch-row ch-info-form">
            <p class="flex">小区名称：</p>
            <div class="flex2">
                <div id="selectChe">

                </div>
                <select id="bs3Select" class="selectpicker show-tick " multiple data-live-search="true" title="请选择"
                        name="xiaoqu">
                </select>

            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex">方案户型：</p>
            <div class="flex2" style="margin-top: 9px;" id="checkboxed">
                {volist name="HouseData" id="vo" key="k" }
                <label class="checkbox-inline">
                    <input type="checkbox"  data-id="{$vo.id}"  class="cb_box" id="HouseData{$k}"  value="{$vo.id},{$vo.title}" name="house"> {$vo.title}
                </label>
                {/volist}
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex">预计工期：</p>
            <div class="flex2">
                <input type="number" class="form-control" name="day" placeholder="请输入预计工期" style="width: 50%" oninput="if(value.length>4)value=value.slice(0,4)">
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex">方案简介：</p>
            <div class="flex2">
                <textarea placeholder="请输入200字以内的描述" id="info" class="ck col-sm-5 col-md-6" maxlength="225" ></textarea>

            </div>
        </div>
        <h2 class="ch-info-title"><span class="glyphicon glyphicon-file"></span>方案标签</h2>
        <div style="width: 100%;justify-content: center;text-align:center;" id="biaoqian" >

        </div>


        <h2 class="ch-info-title"><span class="glyphicon glyphicon-file"></span>方案清单</h2>
        <div class="flex1  ch-row">
            <a class="ch-button ch-blue js" data-id="{$id}" href="javascript:;" title="新增">新增</a>
        </div>
        <div class="title-border">

            <div class="flex1">名称</div>
            <div class="flex1">方量</div>
            <div class="flex1">价格</div>
            <div class="flex1 screen-phone">总金额</div>
            <div class="flex1 screen-phone">备注</div>
            <div class="flex1">操作</div>
        </div>
        <div id="opend">

        </div>

        <h2 class="ch-info-title"><span class="glyphicon glyphicon-file"></span>图片展示</h2>
        <div class="formControls col-xs-8 col-sm-8 col-md-8">
            <div id="uploader-demo">
                <!--用来存放item-->
                <div id="filePicker">选择图片</div>
                <div id="fileList" class="uploader-list">

                </div>
            </div>

        </div>
        <div class="row cl" style="text-align: right; margin-top: 20px;">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <button class="btn btn-primary radius" type="button" data-id="{$id}"><i
                        class="Hui-iconfont">&#xe632;</i> 确认提交
                </button>
            </div>
        </div>
        <div class="ch-more">
            <div class="ch-more-box">
                <div class="ch-more-top">
                    <div class="ch-more-off"></div>
                </div>
                <div class="ch-more-tark">
                    <div class="ch-more-content">

                    </div>
                </div>
            </div>
        </div>
    </form>
    <article class="page-container jijian"
             style="display: none;position: absolute;top:10%;background-color: white;border: 1px solid white;left:4%;width: 90%;height: 78%;color: black;padding: 0;overflow: auto">
        <div class="ch-info-title" style="margin-top: 0; background-color: #0a628f;margin-bottom: 48px"><span
                class="jijianguan" style="color: white; margin-left: 94%;font-size: 11px">关闭</span></div>
        <form action="" method="post" class="form form-horizontal">
            <div class="ch-row ch-info-form">
                <p class="flex1">产品分类：</p>
                <div class="flex2">
                    <select class="chan form-control" name="chan">
                        <option selected="selected">请选择分类</option>
                        <option value="0">套餐</option>
                        <option value="1">单个项目</option>
                        <option value="2">自定义</option>
                    </select>
                </div>
            </div>

            <div class="cp">

            </div>
            <div class="ch-row ch-info-form cdcd">
                <p class="flex1">单价：</p>
                <div class="flex2 ch-row ch-info-form-price">
                    <span>$</span>
                    <input type="text" class="dan1" name="un_Price" readonly="readonly" style="width: 100%;">
                </div>
            </div>
            <div class="ch-row ch-info-form">
                <p class="flex1">方量：</p>
                <div class="flex2 ch-row ch-info-form-price">
                    <input type="text" name="square" style="width: 100%" class="fang">
                    <input type="text" readonly="readonly" name="company"
                           style="width: 20%; border-left: 1px solid #ddd; text-align: right;" class="companys">
                    <span style="width: 30%; border: none; padding-left: 5px;"> /单位</span>

                </div>
            </div>


            <input class="price_rule" readonly="readonly" type="hidden" name="rule">
            <input class="order_id" type="hidden" name='order_id' value="{$id}">
            <input class="agency" type="hidden" name='agency' >


            <div class="ch-row ch-info-form">
                <p class="flex1">总价：</p>
                <div class="flex2 ch-row ch-info-form-price">
                    <span>$</span>
                    <input type="text" class="jia" name="to_prices" readonly="readonly" style="width: 100%">
                    <!-- <span>.00</span> -->
                </div>
                <input type="hidden" class="jias form-control" name="to_price">
            </div>
            <div class="ch-row ch-info-form">
                <p class="flex1">备注：</p>

                <div class="flex2">
                    <div class="flex2">
                        <textarea name="remarks" class="form-control"></textarea>
                    </div>

                </div>
            </div>
            <div class="ch-row ch-info-form">
                <div class="flex1">
                    <button class="btn btn-primary radius1" type="button"><i class="Hui-iconfont">&#xe632;</i> 提交
                    </button>
                </div>
            </div>

        </form>
    </article>
</div>

{include file="public/footer"}
<script>
    var labelList=[];
    $('#checkboxed').find('input[type=checkbox]').bind('click', function(){
        var id = $(this).attr("data-id");

        //当前的checkbox是否选中
        if(this.checked){
            //除当前的checkbox其他的都不选中
            if(id==9){
                $("#checkboxed").find('input[type=checkbox]').not(this).attr("disabled",true);
                $("#checkboxed").find('input[type=checkbox]').not(this).attr("checked",false);
            }

        }else {
            $("#checkboxed").find('input[type=checkbox]').not(this).attr("disabled",false);
            $("#checkboxed").find('input[type=checkbox]').not(this).attr("checked",false);
        }
    });
    $('#scheme_category').find('input[type=checkbox]').bind('click', function(){
        var text="";
        $("input[name=scheme_category]").each(function() {
            if (this.checked) {
                text +=$(this).attr("data-id")+",";
            }
        });
        laber(text)

    });
    $(window).on('load', function () {
        $('.selectpicker').selectpicker({
            'selectedText': 'cat'
        });

    });

    function laber(data) {
        if (data != '') {
            $('#biaoqian').empty();
            $.post("{:url('index/Scheme/schemeLabeltop')}", {param1: data}, function (data, textStatus, xhr) {
                labelList=data;
                var html='';
                for (var i = 0; i < data.length; i++) {
                    var position='';
                    var problem='';
                for (var j = 0; j < data[i].position.length; j++) {
                    position += '<div class="child1" style="display: inline-block ;"><input type="checkbox" name="radio" value="'+data[i].position[j].id+'" style="width: 100%;height:100%;visibility: hidden" id="val_'+data[i].id+data[i].position[j].id+'"><label style="height: 100%; margin-top: -67px;width: 100%;" for="val_'+data[i].id+data[i].position[j].id+'">'+data[i].position[j].title+'</label></div>';
                }
                for (var h = 0; h < data[i].problem.length; h++) {
                    problem += '<div class="child1" style="display: inline-block ;"><input type="checkbox" name="wenti" value="'+data[i].problem[h].id+'" style="width: 100%;height:100%;visibility: hidden" id="val_'+data[i].id+data[i].problem[h].id+'s"><label style="height: 100%; margin-top: -67px;width: 100%;" for="val_'+data[i].id+data[i].problem[h].id+'s">'+data[i].problem[h].title+'</label></div>';
                }
                    html += '<div style="display: inline-block;width: 386px; vertical-align: top;" class="yin"><div style="font-weight:700;text-align: left;padding: 10px;">' + data[i].title + '</div><div style="text-align: left;padding: 10px;">位置</div><div style="text-align: left;"> <div class="parent1">'+position+'</div></div><div style="text-align: left;padding: 10px;">问题类型</div><div style="text-align: left;"><div class="parent1" >'+problem+'</div></div></div>';
                }
                $('#biaoqian').append(html);
                $(".yin").trigger("create");

            })
        }else {
            $('#biaoqian').empty();
        }
    }
    $('#biaoqian').click(function () {



    });



    $(function () {
        var columnTitle = ($(window).width() - 30) * 0.3;
        var columnContent = ($(window).width() - 30) * 0.7;
        $(".ch-column-track").css({
            "width": columnTitle + (columnContent * $(".ch-column-num").length) + 'px',
            "padding-left": columnTitle,
        });
        $(".ch-column-title").css("width", columnTitle);

        $(".ch-column-content").css("width", columnContent);
        for (var i = 0; i < $(".ch-column-title").length; i++) {
            $(".ch-column-title").eq(i).css("height", $(".ch-column-text").eq(i).height())
        }
    })
</script>
<script>

    function get() {
        var id = $('.js').attr('data-id');
        return id;
    }

    function Infrastructure(id) {
        $('#opend').empty();
        var lo = JSON.parse(localStorage.getItem(id));

        if (lo) {
            for (var i = 0; i < lo.length; i++) {

                var html = `
                    <div class="content-border">

                        <div class="flex1">${lo[i].class_b}</div>
                        <div class="flex1">${lo[i].square}</div>
                        <div class="flex1">${lo[i].un_Price}</div>

                       <div class="flex1 screen-phone">${(lo[i].un_Price * lo[i].square).toFixed(2)}</div>
                        <div class="flex1 screen-phone">${lo[i].remarks}</div>
                        <div class="flex1">
                            <a href="javascript:;" class="screen-pc more ch-button ch-blue">更多</a>
                            <a href="javascrtpt:;" class="shan ch-button ch-blue" data-name="${lo[i].class_b}">删除</a>
                        </div>
                    </div>
                `
                $('#opend').append(html);
            }
        }

    }

    $('#bs3Select').change(function (event) { //选择省
        var value=$("#bs3Select").val();
        var title=$("#bs3Select").find("option:selected").text();

        if(value !=null){
            $('#selectChe').append('<span style="margin-right: 9px;" class="glyphicon glyphicon-remove Pointme" ><input value="'+value+'" type="hidden" name="PointmeInput">'+title+'</input></span>')
        }


        $("#bs3Select").selectpicker('deselectAll');


    });
    $(document).on('click', '.Pointme', function () {
       $(this).remove()
    })

    $(document).on("click", ".shan", function () {
        var id = $('.js').attr('data-id');
        var lo = JSON.parse(localStorage.getItem(id));
        var shan = $(this).attr('data-name');
        if (lo) {
            for (var i = 0; i < lo.length; i++) {
                if (lo[i].class_b == shan) {
                    $(this).parent().parent().remove();
                    lo.splice(i, 1);
                    localStorage.setItem(id, JSON.stringify(lo))
                }

            }
        }

    });


    /***
     *
     *
     * 提交代码
     * */
    $('.radius').click(function () {

        var id = $('.js').attr('data-id');
        var scheme_category = [];
        var house = [];
        $("input[name='scheme_category']:checked").each(function () {
            scheme_category.push(this.value)
        });
        if (scheme_category.length == 0) {
            alert('请填写方案类别');
            return false;
        }
        var labelListdata =labelList ;
        var labelListarray = [];
        for (var i = 0; i < labelListdata.length; i++) {
            var labelListId = labelListdata[i].id;
            var radio = [];
            var wenti = [];
            $("[name='radio']").each(function () {
                if ($(this).is(':checked')) {

                    var Id = $('#val_' + labelListId + $(this).val()).val();
                    if (Id) {
                        radio.push({'id': Id})
                    }

                }
            });
            $("[name='wenti']").each(function () {
                if ($(this).is(':checked')) {
                    var Ids = $('#val_' + labelListId + $(this).val() + 's').val();
                    if (Ids) {
                        wenti.push({'id': Ids})
                    }
                }
            });

            labelListarray.push({'biaoti': radio, 'wenti': wenti,'id':labelListId})


        }
        var pan = 0;

        for (var j = 0; j < labelListarray.length; j++) {

            if (labelListarray[j].wenti.length == 0) {
                alert('请选择问题类型');
                return false;
            }
            if (labelListarray[j].biaoti.length != 0) {
                if (labelListarray[j].wenti.length == 0) {
                    alert('请选择问题类型');
                    return false;
                }
            }
            if (labelListarray[j].wenti.length != 0) {
                if (labelListarray[j].biaoti.length == 0) {
                    alert('请选择位置');
                    return false;
                }
            }
            if (labelListarray[j].wenti.length == 0) {
                alert('请选择问题类型');
                return false;
            }
            if (labelListarray[j].wenti.length == 0 && labelListarray[j].biaoti.length == 0) {
                pan += 1;
            }
        }
        if (pan == labelList.length) {
            alert('请选择方案标签');
            return false;
        }
        var lo = localStorage.getItem(id);
        if(lo==null){
            alert('请上传方案清单');
            return false;
        }


        var store_name = $('input[name="store_name"]').val();
        if (store_name == '') {
            alert('请输入方案名称');
            return false;
        }
        var scheme_community =[];
        $("input[name='PointmeInput']").each(function(){
            scheme_community.push($(this).val() );
        });

        if (scheme_community.length==0) {
            alert('请选择小区');
            return false;
        }
        $("input[name='house']:checked").each(function () {
            house.push(this.value)
        });
        if (house.length == 0) {
            alert('请填写方案户型');
            return false;
        }
        var day = $('input[name="day"]').val();
        if (day == '') {
            alert('请填写预计工期');
            return false;
        }
        var info = $("#info").val();
        if (info == '') {
            alert('请填写方案简介');
            return false;
        }
        var src = "{:Url('index/Scheme/add')}?id=";
        // $(this).attr('disabled', true);
        var counts=  $('#fileList').children().length;
        var img=[];
        for (var i=0;i<counts;i++){
            var title= $("#WU_FILE_"+i+"  input[name='title']").val();
            var logo= $("#WU_FILE_"+i+"  input[name='logo']").val();
            if(title==''){
                alert('请填写标题');
                return false;
            }
            img.push({"title":title,'logo':logo})
        }

        $.ajax({
            type: 'POST',
            url: src,
            dataType: 'json',
            data: {
                'scheme_category': scheme_category,
                'dataList': lo,
                'store_name': store_name,
                'scheme_community': scheme_community,
                'house': house,
                'day': day,
                'info': info,
                "labelListarray":labelListarray,
                "img":img,
                'cityid':$('.city1').val(),
                'area':$('.area1').val()
            },
            success: function (data) {
                // $('.radius').attr("disabled", false);
                var res = JSON.parse(data);
                if (res.code == 200) {
                    parent.location.reload()
                } else {
                    layer.msg(res.msg, {icon: 5, time: 1000});
                }

            },
            error: function (data) {
                console.log(data.msg);
            },
        });


    });
    /**
     * 基建
     */
    $('.js').click(function () {
        $('.jijian').css('display', 'block');
        $('.jijianfu').css({
            "position": "fixed",
            "top": "0",
            "left": "0",
            "bottom": "0",
            "right": "0",
            "width": "100%",
            "height": "100%",
            "background": "rgba(0,0,0,0.4)",
        })
    });
    $('.jijianguan').click(function () {
        $('.jijian').css('display', 'none');
        $('.jijianfu').css({
            "position": "",
            "top": "0",
            "left": "0",
            "bottom": "0",
            "right": "0",
            "width": "100%",
            "height": "100%",
            "background": "",
        })



    });
    privance1();

    /* 省市区三级联动 */
    function privance1() //省
    {
        $.post("{:url('index/need/privance')}", {param1: 'value1'}, function (data, textStatus, xhr) {
            var html;
            for (var i = 0; i < data.length; i++) {
                html += "<option value='" + data[i]['province_id'] + "'>" + data[i]['province'] + "</option>";
            }
            $('.province1').html(html);
            city1()
        });
    }


    function city1() //市
    {
        var provinceid = $('.province1').val(); //省id

        $.post("{:url('index/need/city')}", {province_id: provinceid}, function (data, textStatus, xhr) {
            var html;
            for (var i = 0; i < data.length; i++) {
                html += "<option value='" + data[i]['city_id'] + "'>" + data[i]['city'] + "</option>";
            }
            $('.city1').html(html);
            area1();
        });
    }


    function area1() //县
    {
        var cityid = $('.city1').val(); //市id
//alert(cityid);
        $.post("{:url('index/need/area')}", {city_id: cityid}, function (data, textStatus, xhr) {
            var html;
            for (var i = 0; i < data.length; i++) {
                html += "<option value='" + data[i]['county_id'] + "'>" + data[i]['county'] + "</option>";
            }
            $('.area1').html(html);
            f();
        });
    }



    $('.province1').change(function (event) { //选择省

        city1();
        $(".province1").removeAttr('onmouseover')
    });
    $('.city1').change(function (event) { //选择省
        area1();

    });
    $('.area1').change(function (event) { //选择省
        f();

    });


    function f() {
        $('#bs3Select').empty();
        var city = $('.city1').val(); //市id
        var area = $('.area1').val(); //市id
        $.post("{:url('index/Scheme/quartersList')}", {
            city: city,
            name: '',
            area: area
        }, function (data, textStatus, xhr) {
            for (var i = 0; i < data.length; i++) {
                $('.selectpicker').append("<option value=" + data[i]['id'] + ">" + data[i]['name'] + "</option>");
            }

            $('#bs3Select').selectpicker('refresh');
            $('#bs3Select').selectpicker('render');
        });
    }

    $("#img-change").click(function () {
        $("#file").click();
    });

    function delParent(object) {
        $(object).parent().remove();
        count -= 1;
    }

    var count = 1;
    $(function () {
        var $list = $("#fileList");
        var uploader = WebUploader.create({
            auto: true,
            // 文件接收服务端。
            server: "{:Url('index/upload/upload_file')}",

            // 选择文件的按钮。可选。
            pick: '#filePicker',

            // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
            resize: false,
            duplicate: true,
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            },
        });

        // 当有文件添加进来的时候
        uploader.on('fileQueued', function (file) {
            var $li = $(
                '<div id="' + file.id + '" class="file-item thumbnail">' +
                '<div onclick="delParent(this)" style="cursor: pointer;background: url({$Think.DOMAIN_SRC}/static/h-ui/images/del.png) no-repeat;background-size:contain;height: 20px;width: 20px;position: absolute;z-index: 10;right: 5px;"></div>' +
                '<img style="width: 100px;height: 100px;">' +
                '<input name="logo" type="hidden" value="">' +
                '<input type="text"  value="" name="title" placeholder="请输入图片标题" style="border: none;border-bottom: 1px solid #000">' +

                '</div>'
                ),
                $img = $li.find('img');


            // $list为容器jQuery实例
            $list.append($li);

            // 创建缩略图
            // 如果为非图片文件，可以不用调用此方法。
            // thumbnailWidth x thumbnailHeight 为 100 x 100
            uploader.makeThumb(file, function (error, src) {
                if (error) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }

                $img.attr('src', src);
            }, 100, 100);
        });


        // 文件上传过程中创建进度条实时显示。
        uploader.on('uploadProgress', function (file, percentage) {
            var $li = $('#' + file.id),
                $percent = $li.find('.progress span');

            // 避免重复创建
            if (!$percent.length) {
                $percent = $('<p class="progress"><span></span></p>')
                    .appendTo($li)
                    .find('span');
            }


            $percent.css('width', percentage * 100 + '%');
        });
        var s = [];
        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        uploader.on('uploadSuccess', function (file, res) {
            var data = JSON.parse(res._raw);
            if (data.errcode == 300) {
                layer.alert(data.msg);
            }
            var url = data.data;
            count += 1;
            $('#' + file.id).find("logo").attr("src", url);
            $('#' + file.id).find("input").val(url);
            $('#' + file.id).addClass('upload-state-done');
        });

        // 文件上传失败，显示上传出错。
        uploader.on('uploadError', function (file) {
            var $li = $('#' + file.id),
                $error = $li.find('div.error');

            // 避免重复创建
            if (!$error.length) {
                $error = $('<div class="error"></div>').appendTo($li);
            }

            $error.text('上传失败');
        });

        // 完成上传完了，成功或者失败，先删除进度条。
        uploader.on('uploadComplete', function (file) {
            $('#' + file.id).find('.progress').remove();
        });
    });


</script>
<style>
    .parent {
        display: flex;
        flex-wrap: wrap;
        justify-content: start;
    }

    .child {
        /*flex: 0 0 18%;*/
        /*width: 50px;*/
        height: 30px;
        line-height: 30px;
        background: #cbccce;
        margin: 2px;
        border-radius: 5px;
    }

    .parent1 {
        padding-top: 30px;

    }

    .child1 {
        /*flex: 0 0 18%;*/
        padding: 0 5px 0 5px;
        height: 30px;
        line-height: 30px;
        background: #cbccce;
        margin: 1px;
        margin-top: -20px;
        border-radius: 5px;
    }
</style>

<script>
    $('.chan').bind("change", function () {
        $('.shan').remove();

        var cha = $(".chan option:selected").val();
        if (cha == 0) {
            var html = `
                <div class="ch-row ch-info-form shan">
                    <div class="flex1">套餐选择：</div>
                    <div class="flex2 ch-pc-row">
                        <select name="class_a" class="class_a2 form-control class_a3 ch-info-select">
                            <option selected="selected" value="">请选择</option>
                            {volist name="gs" id="v"}
                            <option value="{$v.product_id}">{$v.product_title}</option>
                            {/volist}
                        </select>
                        <select name="class_b" class="class_b form-control">
                            <option selected="selected">请选择问题</option>
                        </select>
                    </div>
                </div>
                `;
            $(".cp").append(html);
            $('.cdcd').css('visibility', 'visible');


        } else if (cha == 1) {

            var html = `
                <div class="ch-row ch-info-form shan">
                    <div class="flex1">清单选择：</div>
                    <div class="flex2 ch-pc-row">
                        <select name="class_a" class="class_a1 form-control class_a3 ch-info-select">
                            <option selected="selected" value="">请选择</option>
                            {volist name="po" id="v"}
                            <option value="{$v.detailed_id}">{$v.detailed_title}</option>\n
                            {/volist}
                        </select>
                        <select name="class_b" class="class_b1 form-control class_b">
                            <option selected="selected">请选择</option>
                        </select>
                    </div>
                </div>
                `;
            $(".cp").append(html);
            $('.cdcd').css('visibility', 'visible');

        } else if (cha == 2) {
            var html =
                `
            <div class="shan">
                <div class="ch-row ch-info-form">
                    <div class="flex1">标题：</div>
                    <div class="flex2">
                        <input type="text" name="class_a" placeholder="请输入标题" class=" form-control class_b">
                    </div>
                </div>
                <div class="ch-row ch-info-form">
                    <div class="flex1">单位：</div>
                    <div class="flex2">
                        <select name="company" class="class_a3 form-control companys">
                            <option selected="selected" name="company" >请选择</option>
                            {volist name="g" id="v"}
                            <option value="{$v.title}">{$v.title}</option>\n
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="ch-row ch-info-form">
                    <div class="flex1">单价：</div>
                    <div class="flex2">
                        <input type="number" name="un_Price" placeholder="请输入标价" class="dan1 form-control" style="margin-bottom: 5px;">
                        </div>
                </div>
                <div class="ch-row ch-info-form shan">
                    <p class="flex1">备注：</p>
                    <div class="flex2">
                        <textarea name="qi_rmakes" class="form-control"></textarea>
                    </div>
                </div>
            </div>
            `
            $(".cp").append(html);
            $('.ll').remove();
            $('.o').remove();
            $('.price_rule').val('');
            $('.fang').val('');
            $('.jias').val('');
            $('.jia').val('');
            $('.cdcd').css('visibility', 'hidden');
        }

    });
    $(document).on("change", ".class_a1", function () {
        var detaileds_id = $(this).val();
        $.post("{:url('index/order/detailed')}", {detaileds_id: detaileds_id}, function (data, textStatus, xhr) {
            var html;
            var artificial;
            var dan;
            var pris;
            var agency;
            if (data.length > 0) {
                for (var i = 0; i < data.length; i++) {
                    html += "<option value='" + data[i]['detailed_id'] + "' >" + data[i]['detailed_title'] + "</option>";
                    artificial = data[0]['artificial'];
                    dan = data[0]['titles'];
                    pris = data[0]['rmakes'];
                    agency = data[0]['agency'];
                }
            } else {
                html += "<option value=''>暂无数据</option>";
            }
            $('.class_b1').html(html);
            $('.dan1').val(artificial);
            $('.companys').val(dan);
            $('.price_rule').val(pris);
            $('.agency').val(agency);
            $('.fang').val('');
            $('.jias').val('');
            $('.jia').val('');


        });
    });
    $(document).on("change", ".class_a2", function () {
        var product_id = $(this).val();

        $.post("{:url('index/order/product_chan')}", {product_id: product_id}, function (data, textStatus, xhr) {
            var html;
            var artificial;
            var dan;
            var price_rule;
            if (data.length > 0) {
                for (var i = 0; i < data.length; i++) {
                    html += "<option value='" + data[i]['product_id'] + "' >" + data[i]['product_title'] + "</option>";
                    artificial = data[0]['prices'];
                    price_rule = data[0]['price_rules'];
                    dan = data[0]['titles'];
                }

            } else {
                html += "<option value=''>暂无数据</option>";

            }
            $('.companys').val(dan);
            $('.class_b').html(html);
            $('.dan1').val(artificial);
            $('.price_rule').val(price_rule);
            $('.fang').val('');
            $('.jias').val('');
            $('.jia').val('');


        });


    });
    $(document).on("change", ".class_b", function () {
        var product_id = $(this).val();

        $.post("{:url('index/order/product_chan_dan')}", {product_id: product_id}, function (data, textStatus, xhr) {
            var artificial;
            var dan;
            var price_rule;
            artificial = data['prices'];
            dan = data['titles'];
            price_rule = data['price_rules'];
            $('.companys').val(dan);
            $('.price_rule').val(price_rule);

            $('.dan1').val(artificial);
            $('.fang').val('');
            $('.jias').val('');
            $('.jia').val('');


        });


    });
    $(document).on("change", ".class_b1", function () {
        var product_id = $(this).val();

        $.post("{:url('index/order/detailed_dan')}", {detaileds_id: product_id}, function (data, textStatus, xhr) {
            var artificial;
            var dan;
            var pris;
            artificial = data['artificial'];
            dan = data['titles'];
            pris = data['rmakes'];
            $('.price_rule').val(pris);
            $('.companys').val(dan);
            $('.dan1').val(artificial);
            $('.fang').val('');
            $('.jias').val('');
            $('.jia').val('');


        });


    });


    $('.fang').bind("change", function () {
        //向input输入框中赋值
        var chan = $('.chan').val();
        var companys = $('.dan1').val();
        var fang = $('.fang').val();

        if (chan == 2) {
            var num = ((companys * 1000) * fang) / 1000;
            num = num.toFixed(2);
            var num1 = ((companys * 1000) * fang) / 1000;
            num1 = num1.toFixed(2);
            $('.jia').val(num);
            $('.jias').val(num1);
        } else {
            var num = ((companys * 1000) * fang) / 1000;
            num = num.toFixed(2);
            var num1 = ((companys * 1000) * fang) / 1000;
            num1 = num1.toFixed(2);
            $('.jia').val(num);
            $('.jias').val(num1);
        }


    });
    /***
     *
     *
     * 提交代码
     * */
    $('.radius1').click(function () {
        var param = [];
        var chan = $('.chan').val();
        var un_Price = $('.dan1').val();
        var remarks =   $("textarea[name=remarks]").val();
        var square = $('.fang').val();
        var agency = $('.agency').val();
        if (chan == 2) {
            var class_a = "自定义项目";
            var company = $('.companys option:selected').val();
            var class_b = $('.class_b').val();
            var projectId = 0;
        } else {
            var class_a = $('.class_a3 option:selected').text();
            var class_b = $('.class_b option:selected').text();
            var projectId = $('.class_b option:selected').val();
            var company = $('.companys').val();

        }
        var order_id = $('.order_id').val();
        var pp = {
            'chan': chan,
            'class_a': class_a,
            'class_b': class_b,
            'un_Price': un_Price,
            'square': square,
            'company': company,
            'order_id': order_id,
            'gong': 0,
            'projectId': projectId,
            'remarks': remarks,
            'agency': agency,
        };

        if (localStorage.getItem(order_id)) {
            var op = JSON.parse(localStorage.getItem(order_id));
            op.push(pp);
            localStorage.setItem(order_id, JSON.stringify(op))
        } else {
            param.push(pp);
            localStorage.setItem(order_id, JSON.stringify(param))

        }
        $('.jijian').css('display', 'none');
        $('.jijianfu').css({
            "position": "",
            "top": "0",
            "left": "0",
            "bottom": "0",
            "right": "0",
            "width": "100%",
            "height": "100%",
            "background": "",
        });
        Infrastructure(order_id);
        $('.chan  option').removeAttr("selected"); //移除属性selected
        $('.fang').val('');
        $('.companys').val('');
        $("textarea[name=remarks]").val('');
        $('.dan1').val('');
        $('.class_b option').removeAttr("selected");

    });


</script>
